﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XukaShop.Models.Entities;

namespace XukaShop.Common
{
    public class CommonFunc
    {
        private static FashionShopEntities _db = new FashionShopEntities();

        /// <summary>
        /// Get string value of Product Type
        /// </summary>
        /// <param name="productTypeId"></param>
        /// <returns></returns>
        public static string GetProductTypeValue(int productTypeId)
        {
            string productTypeValue = string.Empty;
            switch (productTypeId)
            {
                case CommonConst.PRODUCT_TYPE_NORMAL:
                    productTypeValue = CommonConst.STR_PRODUCT_TYPE_NORMAL;
                    break;
                case CommonConst.PRODUCT_TYPE_NEW:
                    productTypeValue = CommonConst.STR_PRODUCT_TYPE_NEW;
                    break;
                case CommonConst.PRODUCT_TYPE_COMMING_SOON:
                    productTypeValue = CommonConst.STR_PRODUCT_TYPE_COMMING_SOON;
                    break;
                case CommonConst.PRODUCT_TYPE_OUT_OF_STOCK:
                    productTypeValue = CommonConst.STR_PRODUCT_TYPE_OUT_OF_STOCK;
                    break;
            }
            return productTypeValue;
        }

        /// <summary>
        /// Get List Gender
        /// </summary>
        /// <returns></returns>
        public static List<Gender> GetListGenderValue()
        {
            List<Gender> lstGenderValue = new List<Gender>();
            lstGenderValue = (from gender in _db.Gender
                              select gender).ToList();
            return lstGenderValue;
        }

        /// <summary>
        /// Get list Size
        /// </summary>
        /// <returns></returns>
        public static List<Size> GetListSize()
        {
            List<Size> lstSize = new List<Size>();
            lstSize = (from size in _db.Size
                       select size).ToList();
            return lstSize;
        }

        /// <summary>
        /// Get list product which have size is avaiable
        /// </summary>
        /// <param name="productCode"></param>
        /// <returns></returns>
        public static List<int> GetListProductSize(string productCode)
        {
            List<int> lstProductSize = new List<int>();
            if (!string.IsNullOrEmpty(productCode))
            {
                lstProductSize = (from productSize in _db.ProductSize
                                  where productSize.ProductCode == productCode
                                  select productSize.SizeId).ToList();

            }
            return lstProductSize;
        }

        /// <summary>
        /// Get List Product Type
        /// </summary>
        /// <returns></returns>
        public static List<ProductType> GetListProductType()
        {
            List<ProductType> lstProductType = new List<ProductType>();
            lstProductType = (from productType in _db.ProductType
                              select productType).ToList();
            return lstProductType;
        }        
    }
}